#include <iostream>

class Car
{
public:
    virtual void show() = 0;
protected:
    std::string name;
};

class BMW:public Car
{
public:
    BMW()
    {
        this->name = "宝马";
    }
    void show()
    {
        std::cout<<name<<std::endl;
    }
};

//装饰者抽象类
class Decorate:public Car
{
public:
    Decorate(Car *c)
    {
        this->c = c;
    }
protected:
    Car *c;
};

class Navigator:public Decorate //导航
{
public:
    //继承父类的所有构造
    #if 1
    using Decorate::Decorate;
    #else
    Navigator(Car *c):Decorate(c){}
    #endif

    void show()
    {
        std::cout<<"导航";
        c->show();
    }
};

class SelfDrive:public Decorate //自动驾驶
{
public:
    using Decorate::Decorate;
    void show()
    {
        std::cout<<"自动驾驶";
        c->show();
    }
};

class VoiceControl:public Decorate //语音控制
{
public:
    using Decorate::Decorate;
    void show()
    {
        std::cout<<"语音控制";
        c->show();
    }
};
int main()
{
    Car *c = new BMW;
    c->show();
 
    Decorate *n = new SelfDrive(c);
    Decorate *d = new Navigator(n);
    Decorate *v = new VoiceControl(d);
    v->show();
    return 0;
}